package views;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

import data.ShowData;

public class ShowFilter extends ViewerFilter
{

    private String searchString;

    public void setSearchText(String s)
    {
        // Search must be a substring of the existing value
        this.searchString = ".*" + s + ".*";
    }

    @Override
    public boolean select(Viewer viewer, Object parentElement, Object element)
    {
        if (searchString == null || searchString.length() == 0)
        {
            return true;
        }
        ShowData data = (ShowData) element;
        if (data.getTitle().matches(searchString))
        {
            return true;
        }
        return false;
    }
}
